package com.changgou.goods.service.impl;

import com.changgou.goods.dao.ParaMapper;
import com.changgou.goods.dao.SpecMapper;
import com.changgou.goods.dao.TemplateMapper;
import com.changgou.goods.pojo.Para;
import com.changgou.goods.pojo.Template;
import com.changgou.goods.service.TemplateService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;
import java.util.Map;

@Service
public class TemplateServiceImpl implements TemplateService {

    @Autowired
    private TemplateMapper templateMapper;
    @Autowired
    private SpecMapper specMapper;
    @Autowired
    private ParaMapper paraMapper;

    /**
     * 添加规格参数数据
     * @param template
     */
    public void add(Template template){
        templateMapper.insert(template);
    }

    /**
     * 根据id删除模板
     * zxq
     * @param id
     */
    @Override
    public void deleteById(Integer id) {
        //清理关联关系
        //根据模板id删除para
        paraMapper.deleteByTemplateId(id);
        //根据模板id删除spec
        specMapper.deleteByTemplateId(id);
        //根据id删除模板
        templateMapper.deleteByPrimaryKey(id);

    }

}
